from flask.json import JSONEncoder
import datetime
import decimal


class MyJSONEncoder(JSONEncoder):
    def default(self, obj):
        if isinstance(obj, decimal.Decimal):
            return str(obj)
        if isinstance(obj, datetime.datetime):
            return obj.strftime('%Y-%m-%d')
        return super(MyJSONEncoder, self).default(obj)
